package com.slf.engine.threads;


import org.apache.log4j.Logger;
import org.apache.log4j.Priority;

import com.slf.engine.common.SysContext;
import com.slf.engine.services.IZjzhService;
import com.slf.engine.services.impl.ZjzhServiceImpl;

public class HeartThread extends Thread {

	private static final Logger log = Logger.getLogger(HeartThread.class);
	
	public HeartThread()
	{
		log.log(Priority.INFO, "HEART_THREAD RUN SUCCESS");
	}
	
	public void run()
	{
		if(SysContext.FREE_TIME == 0)
		{
			SysContext.FREE_TIME = System.currentTimeMillis();
		}
		IZjzhService connService = new ZjzhServiceImpl();
		while(true)
		{
			if(System.currentTimeMillis() - SysContext.FREE_TIME > 1000*60)
			{
				SysContext.FREE_TIME = System.currentTimeMillis();
				log.log(Priority.INFO, "开始执行心跳访问");
				connService.doHeart();
			}else{
				try {
					Thread.sleep(30*1000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
				}
			}
		}
	}
}
